<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: LR0602
  Date: 2021/11/18
  Time: 23:25
  To change this template use File | Settings | File Templates.
--%>
<%--
查找所有用户
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>findall</title>
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>

    <style>
        #mod{
            color: #4cae4c;
        }
        #del{
            color: red;
        }
        #head{
            text-align: center;
            color: #419641;
            size: B4;
        }
    </style>
</head>
<body>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover table-condensed" style="background-color: #9acfea">
        <caption id="head"><h4>用户信息表</h4></caption>
        <tr>
            <th>编号</th>
            <th>网名</th>
            <th>密码</th>
            <th>姓名</th>
            <th>邮箱</th>
            <th>电话</th>
            <th>生日</th>
            <th>性别</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${ub.users}" var="i">
            <tr>
                <td>${i.uid}</td>
                <td>${i.username}</td>
                <td>${i.password}</td>
                <td>${i.name}</td>
                <td>${i.email}</td>
                <td>${i.telephone}</td>
                <td>${i.birthday}</td>
                <td>${i.sex}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/findByIdServlet?uid=${i.uid}" id="mod">修改</a>
                    <a href="javascript:void(0)" id="del" onclick="DeleteUser('${i.uid}')">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
<div>
    <h4 style="text-align: right">共${ub.totalSize}条记录</h4>
    <h4 style="text-align: right">共${ub.totalPage}页</h4>
</div>
<nav aria-label="Page navigation">
    <ul class="pager">
        <c:if test="${ub.currentPage==1}">
            <li><a href="javascript:void(0)" onclick="first()">上一页</a></li>
        </c:if>
        <c:if test="${ub.currentPage!=1}">
            <li><a href="${pageContext.request.contextPath}/findUserByPage?currentPage=${ub.currentPage-1}&pageSize=2">上一页</a></li>
        </c:if>
        <c:if test="${ub.currentPage==ub.totalPage}">
            <li><a href="javascript:void(0)" onclick="last()">下一页</a></li>
        </c:if>
        <c:if test="${ub.currentPage!=ub.totalPage}">
            <li><a href="${pageContext.request.contextPath}/findUserByPage?currentPage=${ub.currentPage+1}&pageSize=2">下一页</a></li>
        </c:if>
        <c:forEach begin="1" end="${ub.totalPage}" step="1" var="j">
            <c:if test="${ub.currentPage==j}">
                <li><h4 class="active">第${j}页&ensp;共${ub.totalPage}页</h4></li>
            </c:if>
        </c:forEach>
    </ul>
</nav>
</body>
<script>
    function DeleteUser(uid) {
        /*弹出确认对话框*/
        var ans = window.confirm("是否确认删除?");
        if(ans){
            window.location.href="${pageContext.request.contextPath}/deleteUserServlet?uid="+uid;
        }
    }
    function first() {
        alert("当前页面已经是第一页!");
    }
    function last() {
        alert("当前页面已经是最后一页!");
    }
</script>
</html>
